package dennis;

public class Task {
	int dd;
	int mm;
	int yy;
	int starttime;
	String strStartTime;
	int endtime;
	String strEndTime;
	String description;
	String venue;
	boolean haslabel;
	boolean hasImportance;
	String label;

	public Task(){ //for creating empty task to use in BasicFeaturesV1
		 dd = 0;
		 mm = 0;
		 yy = 0;
		 starttime = 0;
		 strStartTime = "0";
		 endtime = 0;
		 strEndTime = "0";
		 description = " ";
		 venue = " ";
		 haslabel = false;
		 hasImportance = false;
		 label = "";
	}
	
	public Task(int date, int month, int year, String start, String duetime, String labelname, boolean impt, String task, String place){
		dd=date;
		mm = month;
		yy = year;
		starttime = Integer.parseInt(start);
		endtime = Integer.parseInt(duetime); 
		strStartTime = start;
		strEndTime = duetime;
		label = labelname;
  		
		if(!labelname.isEmpty()){
			haslabel = true;
		}
		
		hasImportance = impt;
		description = task.trim();
		venue = place;
	}

	public int getDate() {
		return this.dd;
	}

	public int getMonth() {
		return this.mm;
	}

	public int getYear() {
		return this.yy;
	}

	public int getWholeDate() {
		return this.dd*10000 + this.mm*100 + this.yy;
	}

	public int getStartTime() { 
		return this.starttime;
	}
 
	public String getstrStartTime(){
		return this.strStartTime;
	}
 
	public String getstrEndTime(){
		return this.strEndTime;
	}
 
	public int getStartTimehours(){
		return (this.starttime/100);
	}
 
	public int getStartTimeminutes(){
		return (this.starttime%100);
	}

	public int getEndTime() {
		return this.endtime;
	}

	public String getDescription(){
		return this.description;
	}

	public boolean hasLabel(){
		return this.haslabel;
	}

	public boolean hasImportance() {
		return this.hasImportance;
	}

	public String getImportance() {
		String astr;
		if(hasImportance()) {
			astr = "* ";
			return astr;
		}
		return " ";
	}
	
	public String getLabel() {
		return this.label;
	}

	public String getVenue(){
		return this.venue;
	}

	public boolean compareTask(Task item) { 
		boolean compare; 
  
		if(this.dd == item.getDate() && this.mm == item.getMonth() && this.yy == item.getYear()  
				&& this.starttime == item.getStartTime() && this.endtime == item.getEndTime() && this.description.equals(item.getDescription()) && this.venue.equals(item.getVenue()) 
				&& this.haslabel == item.hasLabel() && this.hasImportance == item.hasImportance() ){
			compare = true;
		}
		else
			compare = false;
		return compare;
	}
	
	public String printTask(){
		String taskToString = 
		""
		.concat(getImportance())
		.concat(getDateString("ddmmyy")).concat(" ")
		.concat(getstrStartTime()).concat(" ")
		.concat(getstrEndTime()).concat(" ")
		.concat(getDescription()).concat(" ")
	 	.concat(getLabel()).concat(" ")
	 	.concat(getVenue());

		return taskToString;
	}
	
	public String printTask_addIdentifier(){
		//System.out.print("Print Task only\n");
		String taskToString = 
		""
		.concat(getImportance())
		.concat(getDescription()).concat(" ")
		.concat("#").concat(getDateString("ddmmyy")).concat(" ")
		.concat("@").concat(getstrStartTime()).concat("-").concat(getstrEndTime()).concat(" ")
	 	.concat(":").concat(getLabel()).concat(" ")
	 	.concat("$").concat(getVenue());
			
		return taskToString;
		}	
	
	 public String getDateString(String astr){
		 if(astr == "yymmdd")
			 return String.format("%02d",getYear())+String.format("%02d",getMonth())+String.format("%02d",getDate());
		 if(astr == "ddmmyy")
			 return String.format(String.format("%02d",getDate())+String.format("%02d",getMonth())+String.format("%02d",getYear()));
		 return "no string format given";
	 }

}
